Fix gtk4-demo’s gears demo on OpenGL ES
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Fri, 25 Dec 2020 00:21:08 +0000 (01:21 +0100)
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Fri, 25 Dec 2020 00:21:08 +0000 (01:21 +0100)
Here is a command to reproduce this testcase:
GDK_DEBUG=gl-gles gtk4-demo --run gears

Without this patch, Mesa throws this compile error:
0:130(13): error: no matching function for call to `mod(error, float)'; candidates are:

This is caused by `u_rotation - 90` being of type error since
`u_rotation` is a float and it’s illegal to subtract it with an integer.

gsk/resources/glsl/conic_gradient.glsl

index e9dee73e07953400d3faa401c1820a4b2c95a0be..7f73508a3fb32fb64e6b96130686c72a619f5f59 100644 (file)
@@ -15,8 +15,8 @@ void main() {
   gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
 
   // The -90 is because conics point to the top by default
-  rotation = mod (u_rotation - 90, 360.0);
-  if (rotation < 0)
+  rotation = mod (u_rotation - 90.0, 360.0);
+  if (rotation < 0.0)
     rotation += 360.0;
   rotation = PI / 180.0 * rotation;
 
@@ -55,7 +55,7 @@ void main() {
   angle -= rotation;
   // fract() does the modulo here, so now we have progress
   // into the current conic
-  float offset = fract (angle / 2 / PI + 2);
+  float offset = fract (angle / 2.0 / PI + 2.0);
 
   vec4 color = color_stops[0];
   for (int i = 1; i < u_num_color_stops; i ++) {